package 第一个程序;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class TCPClient {
    public static void main(String[] args) throws IOException {
        Socket s = null;
        try{
            s = new Socket("127.0.0.1" , 9999);
            Scanner in = new Scanner(System.in);
            String msg = null;
            while (in.nextLine().equals('q')){
            OutputStream out = s.getOutputStream();
            out.write(msg.getBytes());
            s.close();
            }
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
